package com.etc.service;

import com.etc.dao.ViewLiveinDao;
import com.etc.entity.ViewLivein;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ViewLiveinServiceImpl implements ViewLiveinService{
    @Autowired
    ViewLiveinDao dao;

    /**
     * 查询所有入住信息
     * @param pageNum
     * @param pageSize
     * @param RoomNum
     * @param RtName
     * @param adminName
     * @return
     */
    @Override
    public PageInfo<ViewLivein> getAllLivein(int pageNum, int pageSize,String RoomNum, String RtName, String adminName) {
        //1.开始分页
        PageHelper.startPage(pageNum, pageSize);
        //2.执行查询所有入住信息
        List<ViewLivein> list = dao.queryAllLivein(RoomNum,RtName,adminName);
        //3.通过pageInfo进行包装,PageInfo包含了非常丰富的分页属性
        PageInfo<ViewLivein> pageInfo = new PageInfo<ViewLivein>(list);
        return pageInfo;
    }

    /**
     * 修改结算状态
     * @param IId
     * @return
     */
    @Override
    public boolean getLivein(String IId) {
        int n=dao.upLivein(IId);
        return n>0;
    }
}
